import cv2
import numpy as np

o = cv2.imread('lenacolor.png',1)
h,w,c = o.shape
# 制造掩膜
m = np.zeros((h,w,c),dtype=np.uint8)

m[100:400,200:400]=1
m[100:500,100:200]=1
# 矩阵相乘实现掩膜技术
result = m*o
cv2.imshow('o',o)
cv2.imshow('mask',m)
cv2.imshow('result',result)
cv2.waitKey()
cv2.destroyAllWindows()